<%@tag pageEncoding="UTF-8"%>
<%@attribute name="list" type="java.util.List" required="true" description="属性列表" %>
<%@attribute name="id" type="String" description="select 的id,可选"%>
<%@attribute name="name" type="String" required="true" description="select的name属性，必须"%>
<%@attribute name="clazz" type="String" description="select的class属性"%>
<%@attribute name="selected" type="String" description="被选中的下拉框"%>
<%@attribute name="require" type="Boolean"  description="是否是必填字段，默认不是必填字段会多加一个请选择的选项"%>
<%@attribute name="placeholder" type="String" description="描述信息"%>
<%@attribute name="labelAttr" type="String" description="标签属性名"%>
<%@attribute name="valueAttr" type="String" description="值属性名"%>
<%@attribute name="lang" type="String" description="语言" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<c:set var="idStr" value=""/>
<c:if test="${not empty id }">
<c:set var="idStr" value="id='${id }'"/>
</c:if>
<c:if test="${empty labelAttr }">
    <c:set var="labelAttr" value="label"/>
    <c:set var="valueAttr" value="value"/>
</c:if>
<select name='${name }' ${idStr} class="${empty clazz ? 'form-control' : clazz}"  reg="${reg}" msg="${msg}" >
   <c:if test="${require ne true }">
   <c:choose>
    <c:when test="${empty placeholder }">
    <option value="">--请选择--</option>
    </c:when>
    <c:otherwise>
    <option value="">${placeholder }</option>
    </c:otherwise>
   </c:choose>
   </c:if>
<c:forEach items="${list}" var="each">
    <c:set var="preStr" value=""/>
    <c:if test="${each.rank > 1}">
        <c:forEach begin="2" end="${each.rank}" step="1">
            <c:set var="preStr" value="${preStr }---"/>
        </c:forEach>
    </c:if>
    <option ${selected eq each[valueAttr] ? 'selected="selected"':'' } value="${each[valueAttr] }">${preStr}${each[labelAttr] }</option>
</c:forEach>
</select>
